cmake_minimum_required(VERSION 3.10)
project(NetworkDiskServer C)

# 设置 C 标准
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# 查找 MySQL 库
find_package(PkgConfig REQUIRED)
pkg_check_modules(MYSQL REQUIRED libmysqlclient)

# 查找 pthread 库（可能用于多线程或网络编程）
find_package(Threads REQUIRED)

# 添加 include 目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

# 收集所有源文件
set(SOURCES
    src/main.c
    src/epoll.c
    src/InitTCP.c
    src/shareResInit.c
    src/taskQueue.c
    src/work.c
)

# 添加可执行文件
add_executable(server ${SOURCES})

# 包含 MySQL 头文件
target_include_directories(server PRIVATE ${MYSQL_INCLUDE_DIRS})

# 链接 MySQL、pthread 和其他可能需要的库
target_link_libraries(server PRIVATE ${MYSQL_LIBRARIES} Threads::Threads rt nsl)

# 添加编译选项
target_compile_options(server PRIVATE -Wall -Wextra -O2)
